package com.stoken.web.control;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.stoken.domain.MemberBaseInfo;
import com.stoken.domain.MemberTransinList;
import com.stoken.domain.MemberTransoutList;
import com.stoken.domain.TypeLineInfo;
import com.stoken.service.MemberTransinListService;
import com.stoken.service.MemberTransoutListService;
import com.stoken.web.StokenUtils;
import com.symbio.commons.Compositor;
import com.symbio.commons.Page;
import com.symbio.commons.Compositor.CompositorType;
import com.symbio.utils.WebUtils;

/**
 * 会员转入操作控制
 * @author Frzhao
 *
 */
@Controller
@RequestMapping("/transin")
public class MemberTransinListControl {
	
	@Autowired
	private MemberTransinListService memberTransinListService;
	
	@Autowired
	private MemberTransoutListService memberTransoutListService;
	
	@RequestMapping("/loadTransinData")
	public String traninData(HttpServletRequest request,ModelMap modeMape){
		//获得session里面的user信息
	    MemberBaseInfo  mbi = (MemberBaseInfo) request.getSession().getAttribute(StokenUtils.LOGINACCOUNT);
		Page<MemberTransinList> pageData = new Page<MemberTransinList>();
		//给pageData设置参数
		WebUtils.setPageDataParameter(request, pageData);
		Compositor compositor = new Compositor("id",CompositorType.DESC);
		pageData.setCompositor(compositor);
		pageData.setPageSize(5);
		
		pageData = memberTransinListService.find(pageData,mbi.getBaseUsername());		
	    modeMape.addAttribute("pageData", pageData);
	    
	    Pagination page = new Pagination();
		page.setIntTotalNum((int)pageData.getPagination().getTotalCount());
		page.setCurpage(pageData.getPagination().getPageNo());
		page.setPagenum(pageData.getPagination().getPageSize());
		modeMape.addAttribute("pagination", page.showPages());
		return "/financial/inData";
	}
	
	@RequestMapping("/loadTransoutData")
	public String tranoutData(HttpServletRequest request,ModelMap modeMape){
		//获得session里面的user信息
	    MemberBaseInfo  mbi = (MemberBaseInfo) request.getSession().getAttribute(StokenUtils.LOGINACCOUNT);
		Page<MemberTransoutList> pageData = new Page<MemberTransoutList>();
		//给pageData设置参数
		WebUtils.setPageDataParameter(request, pageData);
		Compositor compositor = new Compositor("id",CompositorType.DESC);
		pageData.setCompositor(compositor);
		pageData.setPageSize(5);
		
		pageData = memberTransoutListService.find(pageData,mbi.getBaseUsername());		
	    modeMape.addAttribute("pageData", pageData);
	    
	    Pagination page = new Pagination();
		page.setIntTotalNum((int)pageData.getPagination().getTotalCount());
		page.setCurpage(pageData.getPagination().getPageNo());
		page.setPagenum(pageData.getPagination().getPageSize());
		modeMape.addAttribute("pagination", page.showPages());
		return "/financial/outData";
	}
}
